package com.letoken.platform.app.configuration;


import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

//@Configuration
public class ImDBConfig {

    @Value("${im.db.url}")
    public String url;

    @Value("${im.db.username}")
    public String username;

    @Value("${im.db.password}")
    public String password;


    public static HikariDataSource imDataSource;

    @PostConstruct
    public void imDatasource() {
        HikariConfig configuration = new HikariConfig();
        configuration.setDriverClassName("com.mysql.cj.jdbc.Driver");
        configuration.setJdbcUrl(url);
        configuration.setUsername(username);
        configuration.setPassword(password);
        configuration.setSchema("im_chat");
        configuration.setMaximumPoolSize(10);
        imDataSource = new HikariDataSource(configuration);
    }
}